package com.pro.service.imple;

import com.pro.mapper.CommentMapper;
import com.pro.mapper.JsMicrocircleMapper;
import com.pro.pojo.JsComment;
import com.pro.pojo.JsCourse;
import com.pro.pojo.JsMicrocircle;
import com.pro.pojo.Product;
import com.pro.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImple implements CommentService {
    @Autowired
    private CommentMapper commentMapper;


    @Override
    public Integer countCommentNum(String type, String userType, String status, String commentDate) {
        return commentMapper.countCommentNum(type, userType, status,commentDate);
    }

    @Override
    public Integer countCommentPeople(String type, String userType, String status,  String commentDate) {
        return commentMapper.countCommentPeople(type, userType, status,commentDate);
    }

    @Override
    public boolean updateStatus(String status, Integer id) {
        return commentMapper.updateStatus(status, id);
    }

    @Override
    public boolean deleteComment(Integer id) {
        return commentMapper.deleteComment(id);
    }

    @Override
    public Integer personalProductNum(Integer createId, String type, String userType, String status, String commentDate) {
        return commentMapper.personalProductNum(createId, type, userType, status, commentDate);
    }

    @Override
    public Integer personalProductPeople(Integer createId, String type, String userType, String status, String commentDate) {
        return commentMapper.personalProductPeople(createId, type, userType, status, commentDate);
    }

    @Override
    public Integer personalCourseNum(Integer createId, String type, String userType, String status, String commentDate) {
        return commentMapper.personalCourseNum(createId, type, userType, status, commentDate);
    }

    @Override
    public Integer personalCoursePeople(Integer createId, String type, String userType, String status, String commentDate) {
        return commentMapper.personalCoursePeople(createId, type, userType, status, commentDate);
    }

    @Override
    public Integer personalMicrocircleNum(Integer userId, String type, String userType, String status, String commentDate) {
        return commentMapper.personalMicrocircleNum(userId, type, userType, status, commentDate);
    }

    @Override
    public Integer personalMicrocirclePeople(Integer userId, String type, String userType, String status, String commentDate) {
        return commentMapper.personalMicrocirclePeople(userId, type, userType, status, commentDate);
    }

    @Override
    public List<JsComment> getUserProductComments(Integer createId,String status) {
        return commentMapper.getUserProductComments(createId,status);
    }

    @Override
    public List<JsComment> getProductComments(Integer createId,String status) {
        return commentMapper.getProductComments(createId,status);
    }

    @Override
    public List<JsComment> getUserCourseComments(Integer createId,String status) {
        return commentMapper.getUserCourseComments(createId,status);
    }

    @Override
    public List<JsComment> getCourseComments(Integer createId,String status) {
        return commentMapper.getCourseComments(createId,status);
    }

    @Override
    public List<JsComment> getUserMicrocircleComments(Integer userId,String status) {
        return commentMapper.getUserMicrocircleComments(userId,status);
    }

    @Override
    public List<JsComment> getMicrocircleComments(Integer userId,String status) {
        return commentMapper.getMicrocircleComments(userId,status);
    }

    @Override
    public boolean addMicrocircleComment(JsComment layForm) {

        layForm.setActicleReviews(layForm.getActicleReviews()+1);
        System.out.println(layForm);
        boolean b = commentMapper.updateMicroCircleActicleReviews(layForm);
        if (b){
            return commentMapper.addMicrocircleComment(layForm);
        }else{
            return false;
        }
    }

    @Override
    public List<JsComment> getTypeComment() {
        return commentMapper.getTypeComment();
    }


    @Override
    public boolean updateDisplay(JsComment param) {
        return commentMapper.updateDisplay(param);
    }


    @Override
    public Product getProductInformation(Integer id) {
        return commentMapper.getProductInformation(id);
    }

    @Override
    public JsCourse getCourseInformation(Integer id) {
        return commentMapper.getCourseInformation(id);
    }

    @Override
    public JsMicrocircle getMicrocircleInformation(Integer id) {
        return commentMapper.getMicrocircleInformation(id);
    }

    @Override
    public List<JsComment> getAllComment(Integer commodityId, Integer type) {
        return commentMapper.getAllComment(commodityId, type);
    }

    @Override
    public List<JsComment> getAllBeforeComment(Integer commodityId, Integer type) {
        return commentMapper.getAllBeforeComment(commodityId, type);
    }

    @Override
    public boolean submitComment(Integer userId, Integer commodityId, Integer parentId, String content, String commentDate, Integer display, Integer type, String userType) {
        return commentMapper.submitComment(userId, commodityId, parentId, content, commentDate, display, type, userType);
    }

    @Override
    public boolean showComment(Integer id, Integer display) {
        return commentMapper.showComment(id,display);
    }

}
